﻿<phoneNavigation:PhoneApplicationPage 
    x:Class="RssReader.MainPage"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
  xmlns:local="clr-namespace:RssReader"
    xmlns:ctrls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
  xmlns:phoneNavigation="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"    
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="800"  
  d:DataContext="{d:DesignData SampleData/MainViewModelSampleData.xaml}"     FontFamily="{StaticResource PhoneFontFamilyNormal}"    FontSize="{StaticResource PhoneFontSizeNormal}"    Foreground="{StaticResource PhoneForegroundBrush}">
    <phoneNavigation:PhoneApplicationPage.Resources>
        <local:DateConverter x:Key="DateConverter"/>
        <local:BoolToOpacityConverter x:Key="BoolToOpacityConverter"/>

        <DataTemplate x:Key="FeedItemWithDateAndFeed">
            <StackPanel Orientation="Horizontal"
                         Opacity="{Binding Path=Read, Converter={StaticResource BoolToOpacityConverter}}">
                <local:ArrowIndicator VerticalAlignment="Center"/>
                <StackPanel Grid.Column="0" Margin="23,0,0,0" VerticalAlignment="Center">
                    <TextBlock Text="{Binding Title}"
                               Style="{StaticResource PhoneTextLargeStyle}"
                               HorizontalAlignment="Left" />
                    <StackPanel Orientation="Horizontal">
                        <TextBlock  Foreground="{StaticResource PhoneAccentBrush}"
                                    Text="{Binding DatePublished, Converter={StaticResource DateConverter}}"
                                    Style="{StaticResource PhoneTextSubtleStyle}"/>
                        <TextBlock  Margin="10,0,0,0"
                                    Foreground="LightGreen"
                                    Text="{Binding ParentFeed.FeedName}"
                                    Style="{StaticResource PhoneTextSubtleStyle}"/>
                    </StackPanel>
                </StackPanel>
            </StackPanel>
        </DataTemplate>

        <Storyboard x:Name="ResetPageTransitionList">
            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="TitleGrid" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)">
                <EasingDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="TitleGrid" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.CenterOfRotationX)">
                <EasingDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="ContentGrid" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)">
                <EasingDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="ContentGrid" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.CenterOfRotationX)">
                <EasingDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Name="PageTransitionList">
            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="TitleGrid" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)">
                <EasingDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                <EasingDoubleKeyFrame KeyTime="00:00:00.3" Value="90">
                    <EasingDoubleKeyFrame.EasingFunction>
                        <CircleEase EasingMode="EaseIn"/>
                    </EasingDoubleKeyFrame.EasingFunction>
                </EasingDoubleKeyFrame>
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="TitleGrid" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.CenterOfRotationX)">
                <EasingDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                <EasingDoubleKeyFrame KeyTime="00:00:00.3" Value="0">
                    <EasingDoubleKeyFrame.EasingFunction>
                        <CircleEase EasingMode="EaseIn"/>
                    </EasingDoubleKeyFrame.EasingFunction>
                </EasingDoubleKeyFrame>
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="ContentGrid" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)">
                <EasingDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                <EasingDoubleKeyFrame KeyTime="00:00:00.3" Value="90">
                    <EasingDoubleKeyFrame.EasingFunction>
                        <CircleEase EasingMode="EaseIn"/>
                    </EasingDoubleKeyFrame.EasingFunction>
                </EasingDoubleKeyFrame>
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="ContentGrid" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.CenterOfRotationX)">
                <EasingDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                <EasingDoubleKeyFrame KeyTime="00:00:00.3" Value="0">
                    <EasingDoubleKeyFrame.EasingFunction>
                        <CircleEase EasingMode="EaseIn"/>
                    </EasingDoubleKeyFrame.EasingFunction>
                </EasingDoubleKeyFrame>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
    </phoneNavigation:PhoneApplicationPage.Resources>
    
    <Grid x:Name="LayoutRoot" Background="{StaticResource PhoneBackgroundBrush}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        
        <Grid x:Name="TitleGrid" Grid.Row="0">
            <Grid.Projection>
                <PlaneProjection/>
            </Grid.Projection>
            <Image Source="/rss.png"
                   Height="40" HorizontalAlignment="Right"
                   VerticalAlignment="Top"
                   Margin="8"
                   Opacity="0.7"/>
            <TextBlock Text="RSS READER" x:Name="textBlockPageTitle" Style="{StaticResource PhoneTextPageTitle1Style}"/>
        </Grid>
        
        <Grid x:Name="ContentGrid" Grid.Row="1">
            <Grid.Projection>
                <PlaneProjection/>
            </Grid.Projection>
            
            <ctrls:Pivot>
                <ctrls:PivotItem Header="Latest News">
                   <ListBox  ItemsSource="{Binding LatestItems}"
                             x:Name="ListBoxTwo" 
                             SelectionChanged="lstLatestItems_SelectionChanged"
                             Style="{StaticResource PhoneListBox}"
                             ItemTemplate="{StaticResource FeedItemWithDateAndFeed}"/>
                </ctrls:PivotItem>
                <ctrls:PivotItem Header="My Feeds">
                    <ListBox x:Name="ListBoxOne" 
                     ItemsSource="{Binding Feeds}" 
                     Style="{StaticResource PhoneListBox}"
                     SelectionChanged="ListBoxOne_SelectionChanged">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal"
                                    Opacity="{Binding Path=Read, Converter={StaticResource BoolToOpacityConverter}}">
                                    <Border x:Name="DataTemplateBorder" Height="44" Width="44"
                                            BorderBrush="White" BorderThickness="2.5" CornerRadius="100"
                                            VerticalAlignment="Top">
                                        <TextBlock Text="{Binding UnReadItems}" Margin="0,-5,0,0"
                                                   HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                    </Border>
                                    <StackPanel Grid.Column="0" Margin="23,0,0,0" VerticalAlignment="Center">
                                        <TextBlock x:Name="ItemText" Text="{Binding FeedName}"
                                            Style="{StaticResource PhoneTextLargeStyle}"
                                            HorizontalAlignment="Left"/>
                                        <TextBlock x:Name="DetailsText" Text="{Binding FeedStatus}"
                                            Foreground="{StaticResource PhoneAccentBrush}"
                                            Style="{StaticResource PhoneTextSubtleStyle}"
                                            HorizontalAlignment="Left"/>
                                    </StackPanel>
                                </StackPanel>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                </ctrls:PivotItem>
                <ctrls:PivotItem Header="Favourites">
                    <ListBox ItemsSource="{Binding FavouriteItems}"
                             x:Name="ListBoxThree" 
                             SelectionChanged="lstLatestItems_SelectionChanged"
                             Style="{StaticResource PhoneListBox}"
                             ItemTemplate="{StaticResource FeedItemWithDateAndFeed}"/>                      
                </ctrls:PivotItem>
            </ctrls:Pivot>
        </Grid>
        
    </Grid>
</phoneNavigation:PhoneApplicationPage>